<?php

namespace App\Http\Controllers;

use App\Order;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class OrderController extends Controller
{
    /*
     * selOrder
     * 查看订单列表
     * 2019-7-25 21:20:54
     * */
    public function selOrder(Request $request){
//        var_dump($request->search);die;
        $name = $request->search;
        if($name==''){
            $data = Order::where(['is_show'=>1])->paginate(3);
            return view('order.orderlist',compact('data'));
        }else{
            $data = Order::where(['is_show'=>1,'name'=>$request->search])->paginate(3);
            return view('order.orderlist',compact('data'));
        }
    }

    /*
     * delOrder
     * 删除订单修改状态
     * 2019-7-25 21:20:32
     * */
    public function delOrder($id)
    {
        $data = Order::findOrFail($id);
        $data->update([
            'is_show'=>0,
        ]);
        return back();
    }
}
